import { getDictionaryApi } from '@/api/Device-all/Device-view'

// 字典查询
const getDictionary = async (name) => {
  const res = await getDictionaryApi(name)
  return res.data.list
}
// 文本输入框/数值输入框
const TextTypeList = [
  {
    componentName: 'NtSwitch',
    span: 12,
    label: '是否隐藏',
    prop: 'hidden',
    rules: [
      {
        required: true,
        message: '请选择是否隐藏',
        trigger: 'change'
      }
    ]
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '占用列数',
    prop: 'colSpan',
    rules: [
      {
        required: true,
        message: '请输入占用列数',
        trigger: 'blur'
      }
    ]
  },
  {
    componentName: 'NtInput',
    span: 24,
    label: '计量单位',
    prop: 'componentUnit'
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '新增值策略',
    isClearable: true,
    prop: 'createValueStrategy',
    selectList: () => getDictionary('VomCreateInitValueStrategy')
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '修改值策略',
    isClearable: true,
    prop: 'updateValueStrategy',
    selectList: () => getDictionary('VomModifyInitValueStrategy')
  }
]

// 下拉选择框
const SelectTypeList = [
  {
    componentName: 'NtSwitch',
    span: 12,
    label: '是否隐藏',
    prop: 'hidden',
    rules: [
      {
        required: true,
        message: '请选择是否隐藏',
        trigger: 'change'
      }
    ]
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '占用列数',
    prop: 'colSpan',
    rules: [
      {
        required: true,
        message: '请输入占用列数',
        trigger: 'blur'
      }
    ]
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '新增值策略',
    isClearable: true,
    prop: 'createValueStrategy',
    selectList: () => getDictionary('VomCreateInitValueStrategy')
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '修改值策略',
    isClearable: true,
    prop: 'updateValueStrategy',
    selectList: () => getDictionary('VomModifyInitValueStrategy')
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '下拉值来源',
    prop: 'comboDataType',
    selectList: () => getDictionary('VomComboDataType'),
    rules: [
      {
        required: true,
        message: '请选择下拉值来源',
        trigger: 'change'
      }
    ]
  }
]

// 字典数据
const zdsjList = [
  {
    componentName: 'NtInput',
    span: 24,
    label: '代码分类',
    prop: 'comboCodeType',
    rules: [
      {
        required: true,
        message: '请输入代码分类',
        trigger: 'blur'
      }
    ]
  },
  {
    componentName: 'NtSwitch',
    span: 12,
    label: '首级代码',
    prop: 'comboTopCode',
    rules: [
      {
        required: true,
        message: '请选择首级代码',
        trigger: 'change'
      }
    ]
  }
]

// 数据库查询
const sjkList = [
  {
    componentName: 'NtInput',
    span: 24,
    textAreaConfig: 'textarea',
    rows: 4,
    label: '查询语句',
    prop: 'comboDataQuery',
    rules: [
      {
        required: true,
        message: '请输入查询语句',
        trigger: 'blur'
      }
    ]
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '查询数据源',
    prop: 'comboDataSource',
    selectList: () => getDictionary('VomComboDataSource')
  }
]

// 多行文本框
const lineList = [
  {
    componentName: 'NtInput',
    span: 12,
    label: '占用行数',
    prop: 'rowSpan',
    rules: [
      {
        required: true,
        message: '请输入占用行数',
        trigger: 'blur'
      }
    ]
  },
  {
    componentName: 'NtInput',
    span: 12,
    label: '占用列数',
    prop: 'colSpan',
    rules: [
      {
        required: true,
        message: '请输入占用列数',
        trigger: 'blur'
      }
    ]
  }
]

// 日期输入框
const dateList = [
  {
    componentName: 'NtSwitch',
    span: 12,
    label: '是否隐藏',
    prop: 'hidden',
    rules: [
      {
        required: true,
        message: '请选择是否隐藏',
        trigger: 'change'
      }
    ]
  },
  {
    componentName: 'NtInput',
    span: 24,
    label: '日期格式',
    prop: 'dateFormat'
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '新增值策略',
    isClearable: true,
    prop: 'createValueStrategy',
    selectList: () => getDictionary('VomCreateInitValueStrategy')
  },
  {
    componentName: 'NtSelect',
    span: 24,
    label: '修改值策略',
    isClearable: true,
    prop: 'updateValueStrategy',
    selectList: () => getDictionary('VomModifyInitValueStrategy')
  }
]
export { TextTypeList, SelectTypeList, zdsjList, sjkList, lineList, dateList }
